"use strict";
cc._RF.push(module, 'e5941l0JxtNYLjxz4BbR7Zr', 'timeOver');
// Script/timeOver.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * 慧眼识珠 游戏 时间耗尽
 */
var GameScene_1 = require("./GameScene");
var gameShareAdsVideo_1 = require("./SdkTools/gameShareAdsVideo");
var PlayData_1 = require("./SdkTools/PlayData");
var storage_1 = require("./SdkTools/storage");
var TipsManager_1 = require("./SdkTools/TipsManager");
var TopUi_1 = require("./TopUi");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var timeOVer = /** @class */ (function (_super) {
    __extends(timeOVer, _super);
    function timeOVer() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.kuang0 = null;
        _this.kuang1 = null;
        _this.kuang2 = null;
        _this.kuang3 = null;
        _this.cha = null;
        _this.challengenum = null;
        _this.getchancebtn = null;
        _this.again = null;
        _this.faile = null;
        _this.success = null;
        _this.title = null;
        _this.overType = -1;
        return _this;
        // update (dt) {}
    }
    // LIFE-CYCLE CALLBACKS:
    timeOVer.prototype.onLoad = function () {
        gameShareAdsVideo_1.default.Instance.recording_Video_End();
        this.kuang0.active = !1;
        this.kuang1.active = !1;
        this.kuang2.active = !1;
        this.kuang3.active = !1;
        if (this.overType == 0) {
            this.kuang0.active = !0;
            this.kuang1.active = !1;
            this.kuang2.active = !1;
            this.kuang0.opacity = 123;
            this.kuang0.scale = 0.3;
            this.faile.active = !1;
            this.success.active = !1;
            cc.tween(this.kuang0)
                .to(0.1, { opacity: 255, scale: 1 })
                .call(function () {
                cc.director.pause();
            })
                .start();
            cc.director.emit('fail');
        }
        else if (this.overType == 2) {
            this.kuang2.active = !0;
            this.kuang2.scale = 0.3;
            cc.tween(this.kuang2)
                .to(0.1, { scale: 1 })
                .call(function () {
                cc.director.pause();
            })
                .start();
            cc.director.emit('fail');
            console.log('复活');
        }
        else if (this.overType == 3) {
            this.kuang3.active = !0;
            this.kuang3.scale = 0.3;
            cc.tween(this.kuang3)
                .to(0.1, { scale: 1 })
                // .call(()=>{
                //     cc.director.pause()
                // })
                .start();
            var gold = storage_1.default.Instance.getGold() + 10;
            storage_1.default.Instance.setGold(gold);
            var top = cc.find('Canvas/top');
            var topsc = top.getComponent(TopUi_1.default);
            topsc.setGold();
        }
        else {
            cc.director.emit('win');
            this.kuang0.active = !1;
            this.initKuang1();
        }
    };
    timeOVer.prototype.onEnable = function () {
        gameShareAdsVideo_1.default.Instance.bannerAds_Show();
        gameShareAdsVideo_1.default.Instance.chaPingAds_Show();
    };
    timeOVer.prototype.onDisable = function () {
        gameShareAdsVideo_1.default.Instance.bannerAds_Hide();
    };
    timeOVer.prototype.setType = function (type) {
        this.overType = type;
    };
    timeOVer.prototype.reliveBtnClick = function () {
        var self = this;
        cc.director.resume(); // 确保游戏不在暂停状态
        gameShareAdsVideo_1.default.Instance.motivational_Video_Show(function () {
            if (PlayData_1.default.Instance.gameType == PlayData_1.GameType.finddifference_zhaobutong) {
                var gamenode = cc.find('Canvas');
                var sc = gamenode.getComponent(GameScene_1.default);
                sc.reliveGame();
            }
            self.node.destroy();
        }, function () {
            console.log('广告未完成，复活未执行');
        });
    };
    timeOVer.prototype.initKuang1 = function () {
        this.kuang1.active = !0;
        // this.kuang1.opacity = 123
        // this.kuang1.scale = 0.3
        // cc.tween(this.kuang1)
        // .to(0.1,{opacity:255,scale:1})
        // .start()
        if (this.overType == 0 || this.overType == 2) {
            this.faile.active = !0;
            this.success.active = !1;
        }
        else {
            this.faile.active = !1;
            this.success.active = !0;
        }
    };
    timeOVer.prototype.closeKuang0 = function () {
        cc.director.resume();
        this.kuang0.active = !1;
        this.initKuang1();
    };
    timeOVer.prototype.closeKuang2 = function () {
        cc.director.resume();
        this.kuang2.active = !1;
        this.initKuang1();
    };
    timeOVer.prototype.againBtn = function (t, e) {
        if (PlayData_1.default.Instance.gameType == PlayData_1.GameType.finddifference_zhaobutong) {
            if (e == 'again') {
                if (storage_1.default.Instance.getEnergy() <= 0) {
                    TipsManager_1.default.Instance.createTips('体力不足');
                    var topsc = cc.find('Canvas/top').getComponent(TopUi_1.default);
                    topsc.openAddEngry();
                }
                else {
                    this.node.destroy();
                    cc.director.resume();
                    this.enterGame4Scene(-1);
                }
            }
            else if (e == 'again2') {
                var self = this;
                gameShareAdsVideo_1.default.Instance.motivational_Video_Show(function () {
                    self.node.destroy();
                    self.enterGame4Scene(1);
                    cc.director.resume();
                }, function () { });
            }
        }
    };
    /**
     * 进入找你妹
     * @param num
     */
    timeOVer.prototype.enterGame4Scene = function (num) {
        console.log('再次进入游戏', num);
        storage_1.default.Instance.setEnergy(storage_1.default.Instance.nowEnery + num);
        var topsc = cc.find('Canvas/top').getComponent(TopUi_1.default);
        topsc.setTiLi();
        var gamenode = cc.find('Canvas');
        if (PlayData_1.default.Instance.gameType == PlayData_1.GameType.finddifference_zhaobutong) {
            var sc = gamenode.getComponent(GameScene_1.default);
            sc.initGame();
        }
    };
    timeOVer.prototype.start = function () {
    };
    timeOVer.prototype.shareGame = function () {
        gameShareAdsVideo_1.default.Instance.recording_Video_Share(function () { }, function () { });
    };
    timeOVer.prototype.backToStartScene = function () {
        cc.director.resume();
        cc.director.loadScene('StartScene');
    };
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "kuang0", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "kuang1", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "kuang2", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "kuang3", void 0);
    __decorate([
        property(cc.Label)
    ], timeOVer.prototype, "cha", void 0);
    __decorate([
        property(cc.Label)
    ], timeOVer.prototype, "challengenum", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "getchancebtn", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "again", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "faile", void 0);
    __decorate([
        property(cc.Node)
    ], timeOVer.prototype, "success", void 0);
    __decorate([
        property(cc.Sprite)
    ], timeOVer.prototype, "title", void 0);
    timeOVer = __decorate([
        ccclass
    ], timeOVer);
    return timeOVer;
}(cc.Component));
exports.default = timeOVer;

cc._RF.pop();